<?php

/**
 * 
 * @version 0.3
 * @author Sander van Belleghem
 * 
 */

require_once 'class/Session.php';
require_once 'class/Authorisatie.php';
require_once 'class/RechtBitfield.php';
require_once 'class/Gebruiker.php';

$session = new Session(); 

if(isset($_GET['action']) && ($_GET['action']) == 'uitloggen'){
    $session->uitloggen();
    echo '<script type="text/javascript">document.location = "index.php";</script>';
}

$ingelogd = (($session->ingelogd() == true) ?  true : false);

if($ingelogd == true) {
    $gebruiker = new Gebruiker();
    $gebruiker->setGebruikerId($session->getSessieVar('gebruiker_id'));
    $data_array = $gebruiker->getGebruikersRecht();

    $data_array_bitfield = $data_array['recht_bitfield'];    
}
    
$page = '';

if(isset($_GET['page'])){
    $page = $_GET['page'];
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Cofely</title>
    <link rel="stylesheet" type="text/css" href="<?php echo FILE_CSS_STYLESHEET; ?>" />
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript" src="<?php echo FILE_JS_VGP; ?>"></script>
    <script type="text/javascript" src="<?php echo FILE_JS_ACTIE; ?>"></script>
    <script type="text/javascript" src="<?php echo FILE_JS_DATEPICKER; ?>"></script>
</head>
<body id="<?php echo $page; ?>">
    <div id="wrapper">
        
    <?php
    
    if($ingelogd == true) {
        echo '<div id="nav">
            <a style="color: #202e85;" href="index.php"><div id="navbutton">Home</div></a>
            <a style="color: #202e85;" href="index.php?action=uitloggen"><div id="navbutton">Uitloggen</div></a>
        </div>';
    }
    ?>
        
        <div id="content">
            
        <?php

        $active = '';
        
            if($ingelogd == true) {
                
                echo '<div id="persoon">';
                echo 'Welkom, <a style="color: black;" href="index.php?page=persoonsgegevens&id=' . $session->getSessieVar('gebruiker_id') . '" >' . $session->getSessieVar('voornaam') . '&nbsp;' . $session->getSessieVar('achternaam') . '</a>'; 
                echo '</div>'; 
                
                if(isset($_GET['page']) && !empty($_GET['page'])){
                    
                    switch ($_GET['page']) {
                        
                        case 'home':
                            include FILE_HTML_HOME;
                        break;

                        case 'toevoegen':
                            include FILE_HTML_TOEVOEGEN;
                        break;

                        case 'overzicht':
                            include FILE_HTML_OVERZICHT;
                        break;
                    
                        case 'overzicht_laag':
                            include FILE_HTML_OVERZICHT_LAAG;
                        break;
                    
                        case 'overzicht_persoon':
                            include FILE_HTML_OVERZICHT_PERSOON;
                        break;
                    
                        case 'overzicht_project':
                            include FILE_HTML_OVERZICHT_PROJECT;
                        break;

                        case 'overzicht_wpi':
                            include FILE_HTML_OVERZICHT_WPI;
                        break;

                        case 'overzicht_vgp':
                            include FILE_HTML_OVERZICHT_VGP;
                        break;

                        case 'toevoegen_persoon':
                            include FILE_HTML_TOEVOEGEN_PERSOON;
                        break;
                    
                        case 'toevoegen_project':
                            include FILE_HTML_TOEVOEGEN_PROJECT;
                        break;

                        case 'toevoegen_persoon';
                            include FILE_HTML_TOEVOEGEN_PERSOON;
                        break;

                        case 'gezondheidsplan':
                            include FILE_HTML_VGP;
                        break;

                        case 'werkplekinspectie':
                            include FILE_HTML_WERKPLEKINSPECTIE;
                        break;

                        case 'presentielijst':
                            include FILE_HTML_PRESENTIELIJST;
                        break;

                        case 'statistieken':
                            include FILE_HTML_STATISTIEKEN;
                        break;

                        case 'zoeken':
                            include FILE_HTML_ZOEKEN;
                        break;

                        case 'instellingen':
                            include FILE_HTML_INSTELLINGEN;
                        break;

                        case 'persoonsgegevens':
                            include FILE_HTML_PERSOONSGEGEVENS;
                        break;

                        case 'aanpassen_sjabloon_wpi';
                            include FILE_HTML_AANPASSEN_SJABLOON_WPI;
                        break;
                    
                        case 'registreren';
                            include FILE_HTML_REGISTREREN;
                        break;
                    
                        case 'bedrijfsonderdeel':
                            include FILE_HTML_BEDRIJFSONDERDEEL;
                        break;
                    
                        case 'laag':
                            include FILE_HTML_LAAG;
                        break;
                    
                        case 'overzicht_sjabloonlijst':
                            include FILE_HTML_OVERZICHT_SJABLOONLIJST;
                        break;
                    
                        case 'sjabloon_aanpassen';
                            include FILE_HTML_SJABLOON_AANPASSEN;
                        break;
                    
                        case 'overzicht_sjabloon':
                            include FILE_HTML_SJABLOON_BEKIJKEN;
                        break;
                    
                        case 'sjabloon_verwerken':
                            include FILE_HTML_SJABLOON_VERWERKEN;
                        break;    
                    
                        case 'recht_toevoegen':
                            include FILE_HTML_RECHT_TOEVOEGEN;
                        break;
                    
                        case 'overzicht_tbm':
                            include FILE_HTML_OVERZICHT_TBM;
                        break;
                       
                        case 'toevoegen_laag':
                            include FILE_HTML_TOEVOEGEN_LAAG;
                        break;
                    
                        case 'toevoegen_onderdeel':
                            include FILE_HTML_TOEVOEGEN_ONDERDEEL;
                        break;
                    
                        case 'dashboard_vgp';
                            include FILE_HTML_DASHBOARD_VGP;
                        break;
                    
                        case 'dashboard_wpi';
                            include FILE_HTML_DASHBOARD_WPI;
                        break;
                    
                        case 'form_rechten';
                            include FILE_HTML_RECHT_TOEVOEGEN;
                        break;                    
                                     
                        case 'aanpassen_persoon';
                            include FILE_HTML_PERSOON_AANPASSEN;
                        break;
                    
                        case 'wachtwoord_aanpassen';
                            include FILE_HTML_WACHTWOORD_AANPASSEN;
                        break;  
                        case 'vgp_del';
                            include FILE_VGP_DEL;
                        break; 
                        case 'vgp_form';
                            include FILE_VGP_FORM;
                        break; 
                        
                        case 'pdf';
                            include FILE_HTML_PDF;
                        break;
                    
                    }
                } else {
                    include FILE_HTML_HOME;
                }
            } else {
                include FILE_HTML_LOGIN;
            }
        ?>
        </div>
    </div>
</body>
</html>
